#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include "uart.h"
#include <QMetaType>
#include<QThread>
#include"serial.h"
#include "cserialobject.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE


class cWidget : public QWidget
{
    Q_OBJECT

public:
    cWidget(QWidget *parent = nullptr);
    ~cWidget();

    enum eSerialBaudRate
    {
        B9600 = 9600,
        B19200 = 19200,
        B38400 = 38400,
        B115200 = 115200
    };
    Q_ENUM(eSerialBaudRate)

    cUart* pcUartInst;
    QString GetSerialName();
    int GetSerialBaudRate();

    QThread qcChildThread;
    CMSerial cmSerial;

    CSerialObject* cSerialObj = nullptr;
    QThread* qcThreadObj = nullptr;


public slots:
    void SerialThreadFinDone();
    void StopThread();

signals:
    void SSS();
    void SSS2();
    void sign_send_frame(QByteArray data);


protected:


public slots:
    void slot_show_frame(QByteArray data);


private:
    void SerialOpen();
    void SerialCancel();

    Ui::Widget *ui;
    int iSerialIndex;               //选中串口的索引
    QStringList qslSerialName;      //保持所有串口的名字,com1,com2...
    QStringList qslSerialDescName;  //保持所有串口的描述和名称，USB-to-serial,COM31
    QStringList qslBaudRate;

    QByteArray testarray;

};
#endif // WIDGET_H
